﻿using Appliaction.Dto.FG;
using Appliaction.IAppServices.FG;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace API.Controllers.FG
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class FG_Finished_Goods_StoreController : ControllerBase
    {
        private readonly IFG_Finished_Goods_StoreService fG_Finished_Goods_StoreService;

        public FG_Finished_Goods_StoreController(IFG_Finished_Goods_StoreService fG_Finished_Goods_StoreService)
        {
            this.fG_Finished_Goods_StoreService = fG_Finished_Goods_StoreService;
        }

        /// <summary>
        /// 分页条件查询成品入库信息
        /// </summary>
        /// <param name="Warehouse_Code"></param>
        /// <param name="code"></param>
        /// <param name="currentPage"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        [HttpGet]
        public JsonResult Get_Finished_Goods_Store_Infos(string? Warehouse_Code, string? code, int currentPage, int pageSize, char auditStatus)
        {
            return new JsonResult(fG_Finished_Goods_StoreService.Get_Finished_Goods_Store_Infos(Warehouse_Code,code,currentPage,pageSize, auditStatus));
        }

        /// <summary>
        /// 条件查询成品入库总数
        /// </summary>
        /// <param name="Warehouse_Code"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<JsonResult> Get_Finished_Goods_StoreCountAsync(string? Warehouse_Code, string? code, char auditStatus)
        {
            return new JsonResult(await fG_Finished_Goods_StoreService.Get_Finished_Goods_StoreCountAsync(Warehouse_Code,code,auditStatus));
        }

        /// <summary>
        /// 添加成品入库信息及其明细
        /// </summary>
        /// <param name="finishedGoodsStoreDetailsAddDto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<JsonResult> FG_Finished_Goods_StoreAddAsync([FromBody] FinishedGoodsStoreDetailsAddDto finishedGoodsStoreDetailsAddDto)
        {
            return new JsonResult(await fG_Finished_Goods_StoreService.FG_Finished_Goods_StoreAddAsync(finishedGoodsStoreDetailsAddDto));
        }

        /// <summary>
        /// 根据成品入库编号查询成品入库信息
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<JsonResult> GetFG_Finished_Goods_StoreByCodeAsync(string code)
        {
            return new JsonResult(await fG_Finished_Goods_StoreService.GetFG_Finished_Goods_StoreByCodeAsync(code));
        }

        /// <summary>
        /// 根据成品入库编号查询成品入库明细
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<JsonResult> Get_Finished_Goods_Store_DetailsByCodeAsync(string code)
        {
            return new JsonResult(await fG_Finished_Goods_StoreService.Get_Finished_Goods_Store_DetailsByCodeAsync(code));
        }

        /// <summary>
        /// 修改成品入库信息及其明细
        /// </summary>
        /// <param name="finishedGoodsStoreDetailsUpdateDto"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<JsonResult> FG_Finished_Goods_StoreUpdateAsync([FromBody] FinishedGoodsStoreDetailsUpdateDto finishedGoodsStoreDetailsUpdateDto)
        {
            return new JsonResult(await fG_Finished_Goods_StoreService.FG_Finished_Goods_StoreUpdateAsync(finishedGoodsStoreDetailsUpdateDto));
        }

        /// <summary>
        /// 逻辑删除成品入库信息
        /// </summary>
        /// <param name="fG_Finished_Goods_StoreDelDto"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<JsonResult> FG_Finished_Goods_StoreDelAsync(FG_Finished_Goods_StoreDelDto fG_Finished_Goods_StoreDelDto)
        {
            return new JsonResult(await fG_Finished_Goods_StoreService.FG_Finished_Goods_StoreDelAsync(fG_Finished_Goods_StoreDelDto));
        }

        /// <summary>
        /// 修改成品入库审核状态、减少库存预计出库数量，增加库存数量
        /// </summary>
        /// <param name="fG_Finished_Goods_StoreUpdateAuditDto"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<JsonResult> FG_Finished_Goods_StoreUpdateAuditAsync(FG_Finished_Goods_StoreUpdateAuditDto fG_Finished_Goods_StoreUpdateAuditDto)
        {
            return new JsonResult(await fG_Finished_Goods_StoreService.FG_Finished_Goods_StoreUpdateAuditAsync(fG_Finished_Goods_StoreUpdateAuditDto));
        }
    }
}
